A color image contrast enhancement method based on improved PSO

Image contrast enhancement uses the object intensity transformation function to maximize the amount of information to enhance an image. In this paper, the image enhancement problem is regarded as an optimization problem, and the particle swarm algorithm is used to obtain the optimal solution. First, an improved particle swarm optimization algorithm is proposed. In this algorithm, individual optimization, local optimization, and global optimization are used to adjust the particle’s flight direction. In local optimization, the topology is used to induce comparison and communication between particles. The sparse penalty term in speed update formula is added to adjust the sparsity of the algorithm and the size of the solution space. Second, the three channels of the color images R, G, and B are represented by a quaternion matrix, and an improved particle swarm algorithm is used to optimize the transformation parameters. Finally, contrast and brightness elements are added to the fitness function. The fitness function is used to guide the particle swarm optimization algorithm to optimize the parameters in the transformation function. This paper verifies via two experiments. First, improved particle swarm algorithm is simulated and tested. By comparing the average values of the four algorithms under the three types of 6 test functions, the average value is increased by at least 15 times in the single-peak 2 test functions: in the multi-peak and multi-peak fixed-dimension 4 test functions, this paper can always search for the global optimal solution, and the average value is either the same or at least 1.3 times higher. Second, the proposed algorithm is compared with other evolutionary algorithms to optimize contrast enhancement, select images in two different data sets, and calculate various evaluation indicators of different algorithms under different images. The optimal value is the algorithm in this paper, and the performance indicators are at least a 5% increase and a minimum 15% increase in algorithm running time. Final results show that the effects the proposed algorithm have obvious advantages in both subjective and qualitative aspects.


Introduction
The contrast of an image is an important factor affecting its quality. The enhancement of the contrast of an image is a process that increases the dynamic range for visual effects and highlighting details. As image processing research deepens in the fields of vision, remote machine learning. While enhancing the image contrast, the method shortens the time required for the evolutionary algorithm to optimize the image. It also largely improves the image quality. This study provides a new idea for the enhancement of low-contrast images in the future. The rest of this article is organized as follows. Section 2 sorts out the relevant literature, makes a theoretical comparison with the existing methods, and introduces the traditional PSO algorithm. Section 3 proposes an improved version of PSO and enhances image contrast on the basis of the improved PSO algorithm. Section 4 evaluates the method in extensive experiments. Finally, Section 5 concludes the paper.

Related work
Contrast enhancement algorithms aim to provide an image with additional vivid colors and higher detail clarity. Contrast enhancement algorithms are closely related to different visual properties. Attributes include brightness, hue, color, hue, and saturation. Existing image enhancement techniques are mostly empirical or heuristic methods that are strongly correlated to specific types of images and usually aim to improve the contrast of degraded images during acquisition. In fact, finding the optimal grayscale map that adaptively enhances each different input image can be viewed as an optimization problem.
In recent years, many bionic algorithms for image enhancement have been developed, such as particle swarm algorithm(PSO), artificial bee colony algorithm, genetic algorithm, and cuckoo algorithm, among others.
Genetic algorithm [14] can be used as a preprocessing step to enhance the histogram distribution near the bimodal image and improve the effect of downstream image processing technology. Munteanu and Rose [15] proposed another genetic algorithm-based contrast enhancement method. This paper uses a four-parameter local/global transformation function and optimizes these parameters by genetic algorithm. The objective function combines the entropy of the enhanced image, the number of edge pixels, and the sum of edge intensity.
In [16], a new enhanced cuckoo search (ECS) algorithm is proposed to realize the automatic enhancement of image contrast by optimizing the local/ global transformation parameters. In the ECS image enhancement algorithm, the sum of the entropy, number of edge pixels, and edge strength are used to construct the objective function. A new local/ global enhancement transform parameter search range is proposed to overcome the problems of local/ global enhancement transforms in enhancing edges, and distorted images achieve better enhancement effects. A method for contrast enhancement of fingerprint images based on cuckoo search (CS) was proposed in [17]. In [17], the fingerprint image is enhanced using grayscale mapping transformation, and the grayscale between the input image and the enhanced image is mapped using the CS algorithm. Here, a parameter Pa called abandonment probability is used to update the solution in each iteration. The improved CS algorithm uses Cauchy mutation to reconstruct Pa worst nests. In [18], an adaptive image enhancement algorithm with hybrid CS and PSO (CSPSO) search algorithm was proposed. Here, an incomplete beta function is used as the boosting transform, and the worst CS set is updated using the PSO algorithm instead of reconstructing the worst set Pa such as the CS algorithm. Recently, an adaptive CS algorithm was proposed for satellite image contrast enhancement in [19], which has the same local/global enhancement transformation and parameter range as [14], with discovery and mutation randomization instead of fixed Pa, generates a new solution and proposes a medical image enhancement algorithm based on wavelet masking. In this paper, Pa is not fixed but adaptive through adaptive crossover and mutation process.
In [20], a new target fitness function is proposed for the indispensable fitness function in the enhanced image quality evaluation, including four performance indicators, namely, the sum of edge strengths, the edges of the number of pixels, image entropy, and image contrast. The fitness function automatically measures the quality of the generated image, and the artificial bee searches for the optimal conversion function under the guidance of the new cost function. Second, this paper uses the incomplete beta function as the image transformation function to guide the search action of artificial bees. Image enhancement based on firefly algorithm is proposed in [21] using the same transformation and objective function as [14]. A method for contrast enhancement of grayscale and color images using artificial bee colony algorithm is proposed. Furthermore, in [1], using the same local/global transformation functions and parameter ranges as [14], an improved differential evolution algorithm is proposed for contrast enhancement of satellite images. However, it uses a different fitness function that combines entropy, edge information, and standard deviation.
In [22], the intensity transform function serves as a traditional particle swarm algorithm to maximize the information amount of the enhanced image. A parametric transformation function that utilizes local and global information from the image is used. An objective criterion for image enhancement considering image entropy and edge information is proposed to achieve the best enhancement effect. Zhang [23] proposed a sonar image enhancement method on the basis of particle swarm optimization. Sonar images have important characteristics such as low resolution, strong echo interference, small target area, and blurred target edges. In this case, obtaining satisfactory results using the global image enhancement algorithm is difficult. In this paper, an adaptive local enhancement algorithm is proposed, which uses edge count, edge strength, and entropy to evaluate enhanced images. Particle swarm optimization (PSO) is used to determine the best enhancement parameters. Kanmani [24] proposed an optimized color contrast enhancement algorithm to improve the visual perception of information in images using an adaptive gamma correction factor selected by particle swarm optimization (PSO) to improve entropy and enhance image detail. And Kanmani [25] proposed a new Eigen face recognition method that uses particle swarm optimization (PSO), self-tuning particle swarm optimization (STPSO), and brainstorm optimization (BSO) to determine the optimal fusion coefficient. To fuse CT and MRI images. And they used PSO to optimize the weights to obtain the weighted average fusion image information, and the objective function jointly maximized the entropy and minimized the root mean square error to improve the image quality [26].

Particle swarm optimization algorithm
This section provides a brief introduction of the PSO algorithm. PSO algorithm [27] is an evolutionary algorithm. Its optimization process is performed by simulating the foraging phenomenon of bird flocks in nature. When bird flocks search for food within a certain range to find the optimal food source, the memory performance must remember the best food it passed and its location after communicating with its peers. After searching through the layers of birds, the birds are guided toward the optimal food location to find the most excellent food source.
The PSO algorithm optimization process is described briefly as follows: Initialize: initialize particle swarm parameters, velocity range, space dimension, maximum iterations, population size, acceleration factor, etc.
Update: In the update iteration process, the speed and position update formula of traditional PSO is as follows: where x represents the position, v represents the speed, and p represents the optimal solution. The individual optimal solution is p b,j , and the global optimal solution is p g,j . i represents the current particle, j refers to the current dimension, t is the current number of iterations, and c 1 and c 2 represent the acceleration factor of the learning factor. The value is usually between 0-2, and r 1,j *U(0,1) and r 2,j *U(0,1) represent two independent random functions.
Determine: if the iteration termination condition is met, terminate the iteration and output the global optimum. Otherwise, return to the previous step to continue the iterative calculation.

Proposed PSO-based image contrast enhancement approach
In summary, this paper uses the advantages of particle swarm algorithm with few parameters, fast search speed, and simple structure. It also proposes an image contrast enhancement method on the basis of improved particle swarm algorithm. Color image processing usually processes R-, G-, and B sub-channels but ignores the relevant information between the three sub-channels. In this paper, the color image is represented by a quaternion matrix, and the quaternion matrix is processed directly. Second, the method uses an improved particle swarm algorithm to optimize the parameters and determine the optimal pixel value in the entire image intensity space. The traditional PSObased image contrast enhancement method involves finding the optimal value in the solution space by using the global optimal and self-optimized adjusting particles to allow its easy fall into the position of the local optimal solution. This paper adds a topology structure to adjust the local optimal solution. The global optimal, local optimal, and individual optimal jointly adjust the particle's flying speed to avoid premature convergence. Intuitively, if the resolution of the image increases, the solution space of the particle swarm will increase. Therefore, the time complexity of the algorithm will increase considerably. To overcome this challenge, this paper adds a sparse penalty term to the particle swarm algorithm, thereby adjusting the sparsity of the algorithm and the size of the solution space.
Finally, a new fitness function is proposed. The chroma of a color image is the key to enhancing image contrast [20]. However, traditional PSO-based image contrast enhancement methods ignore this information. Hence, a new performance indicator is incorporated into the cost function of the method. The proposed new fitness function includes five performance indicators: (a) the sum of edge strengths, (b) the number of edge pixels, (c) the color entropy, (d) the image contrast, and (e) the chroma of the image. This fitness function automatically measures the quality of the generated image and determines the quality of the enhanced image. Therefore, the particle swarm optimization algorithm seeks the optimal transfer function under the guidance of the new cost function.

Proposed PSO
Through the description of the existing PSO algorithm, although a large number of research results have been obtained, problems persist such as being trapped easily in local optimum, premature convergence, and insensitivity to finding the optimal solution for multi-peak functions. For such issues, in this paper, we use the topology structure to improve the PSO and increase the diversity of particles. Topology [28] is typically used in optimization algorithms to refer to the communication methods and neighborhood relationships among individuals in a group. It can control information transmission between particles. The most important thing in the PSO algorithm is the cooperative behavior of particles between groups. Through cooperation and communication between particles, their states change as they search for the global optimum. Topology can change the neighbors of particles and change communication between particles. The local optimal solution after topology communication is used as an item, and the particle's flight direction is adjusted together with the global and individual optimum. Fig 1 shows that after the topology is initialized, the population is divided into several adjacent regions according to the subscripts of the particles, that is, particles x 1 and x 2 can be regarded as adjacent in an adjacent region with a radius of 1. Regardless of the spatial position of the particle, according to the spatial position of the particle, in each iteration of the algorithm, the distance between one particle and other particles in the population is calculated, and the variable d max is used to mark the maximum distance between any two particles; for each particle, the ratio of kx a − x b k/d max is also calculated, where kx a − x b k is the distance from the current particle a to another particle b, using the calculated smaller ratio as the basis for selecting adjacent particles. The ratio is used as the basis for selecting adjacent particles. According to the selection of four nearest neighbors as a group, they are connected in pairs; they also communicate with each other and calculate the fitness value of each particle. According to the fitness value function, the optimal value directly enters the upper layer as the parent node. The calculation method is the same as that of the previous layer on the layer of the parent node. If redundant particles exist, they are directly placed in the next layer for communication and comparison, and so on, until the global optimum is found.
The biggest feature of the particle swarm optimization algorithm is to use the iterative process to solve the optimal value, but it takes a very long time to complete the iterative process. Therefore, this paper adds a sparse penalty term to improve this problem. The sparse penalty term [29] is a concept in machine learning. After comparing the individual optimal, local optimal, and global optimal in the particle swarm, some of the most inferior solutions will be obtained, that is, redundant terms. Using the sparse penalty term to eliminate the last solution in the next iteration, these least solutions can be ignored, the sparsity of the algorithm can be addressed, and the size of the solution space determined.

PLOS ONE
Therefore, the global, local, individual optimal values and sparse penalty term are added to the speed and position update formula. The updated formula is as follows: In Eq (3)), k is the constriction factor, ω is the inertia weight, p b,j is the best solution of the individual particles, p l,j is the best solution of the particles in the local neighborhood, and p g,j is the best solution of the global particles that are recorded, where L 1 = λw 1 are sparse penalty terms, λ is the penalty coefficient, w 1 is the weight of the last solution, c 1 denotes adjusting the individual optimal acceleration coefficient, c 2 denotes adjusting the local optimal acceleration coefficient, c 3 denotes adjusting the global optimal acceleration coefficient, and r 1 , r 2 , r 3 2 (0, 1) are independent of each other.
Notably, in the improved particle swarm algorithm, considering the different values obtained in each run, deviations are anticipated. Therefore, in the experiment, this paper tests each particle swarm algorithm in each test function. Averaged over 30 runs, when optimizing the four parameters in the transformation function, the average value obtained each time is used to optimize. Thus, in the data set experiment, only one result is obtained.

Proposed image contrast enhancement approach
For color image enhancement, this paper uses quaternions to represent color images. In subsequent processing, only quaternion matrices are processed. Quaternion [30] is a mathematical concept that represents super complex numbers. It is composed of the real part plus three virtual parts: i, j, k. The following rules are met between the three virtual parts: From here, we can know that each quaternion can be linearly expressed by 1, i, j, k, then, the general expression of a quaternion is In recent years, quaternions have been used widely often in signal processing [31], coordinate solving [32], and image processing [33]. The quaternion represents a color image that avoids the correlation among R, G, and B during the subchannel processing. The quaternion representation of color images is used generally in the literature [34]. Let the three imaginary components of the quaternion represent the three primary color components of red (R), green (G), and blue (B); additionally, the real part is 0, which can represent each pixel of a color image as a pure quaternion.
Among them, f R (x,y), f G (x,y), and f B (x,y) represent the R, G, and B components of the color image, respectively; and x, y represent the coordinates of the image matrix where the pixel is located. In this way, the color image can be represented by a pure quaternion matrix. Quaternion-based color image processing is used to handle its quaternion matrix. Compared with the traditional sub-channel or the method of transforming to grayscale image and then processing, the quaternion method can better reflect the color image holism, whether for theoretical innovation or practical application, which provides a new direction.
According to the introduction in the previous section, two main factors should be considered when applying the PSO algorithm to image contrast enhancement: (i) Design of a transformation function that will generate a new pixel intensity of the enhanced image from the original image; and (ii) Design of fitness function that checks the quality of the generated image. These important factors affect the quality of enhanced images and are thoroughly described in the following sections.

Transformation function.
A contrast function is used to enhance the contrast of the image in the spatial domain. The transform function generates a new intensity for each pixel of the original image and generates an enhanced image. In this paper, a low-illumination image is mapped by a transformation function to obtain a high-contrast image. This article uses the local/ global enhancement transformation proposed in [35] to use local image statistics, such as mean, variance, and global image information. This function is an extended version of the local enhancement function in [36]. Transform is applied to each pixel of the image of size M � N at position (x, y), and the old intensity f (x, y) is mapped to the new intensity value g (x, y). The formula of this transformation function is In Eq (6), κ, a, b, and c are four parameters, m (x, y) is the local mean of the (x, y) th pixel of the input image over a n×n window. G m is the global mean, and σ (x, y) is the local standard deviation of (x, y) th pixel of the input image over a n×n window, which are defined as follows: s i; j ð Þ ¼ ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi Eq (6) has four unknown parameters, i.e., κ, a, b, and c, and these parameters cause considerable changes to the processed image. It enhances low-contrast images with a local mean enhancement center. The local mean and local standard deviation define the local brightness and contrast of the image, respectively. Parameter an introduces smoothness and brightness effects in the image, while b introduces an offset from the standard deviation in the neighborhood. Parameter c controls how much the average value is to be subtracted from the image f (u, v). Finally, parameter κ controls the global enhancement of the image. For these four optimization parameters, the parameter search range given by different authors is different, which affects the quality of the enhanced image. In [36], the parameter b is set to zero, which makes the master dependent on the local variance. Therefore, zero local variance causes instability in the conversion. In addition, parameters a, c, and κ are set to 1, which limits the optimal choice of parameters to achieve the best performance. In [22], the parameters are as follows: a, b, and c can have any true positive non-zero value, and κ remains between 0.5 and 1.5. Therefore, the purpose of the optimization algorithm is to determine the values of these parameters on the bases of a given objective function, thereby obtaining the best-enhanced image.
3.2.2 Fitness function. As mentioned above, another factor that affects the enhancement of image contrast is the fitness value function. The fitness function is an objective evaluation criterion for automatically measuring the quality of the generated image. Enhancing image quality is the key to determining image quality. Intuitively, compared with the original image, the enhanced image needs other edges, higher edge strength, and higher contrast. For color images, chroma is a judgment index. On the basis of this fact, a new fitness function is proposed, which contains four performance indicators: (i) the sum of edge strength, (ii) the number of edge pixels, (iii) color entropy, (iv) image contrast, and (v) Chroma. More specifically, given the original image, this method will enhance the image and generate an enhanced image on the basis of the following fitness function. In this paper, the formula is expressed as follows: Where I e is the enhanced image of the original image. I s is an edge image on the produced enhanced image. E(I s ) is the image edge intensity, H(I e ) is the color entropy, n_edgels(I s ) is the number of image edge pixels, C(I e ) is the image contrast, and I(I e ) is the image brightness. Image contrast refers to the measurement of different brightness levels between the brightest white and the darkest black in the light and dark areas of an image, that is, the magnitude of the gray contrast of an image. The larger the range of difference, the more vivid and rich colors can be easily displayed. The image contrast calculation formula is Where δ(i, j) = |i − j| is the quaternion difference between adjacent pixels, and P δ (i, j) is the pixel distribution probability of quaternion difference between adjacent pixels. Image entropy is expressed as the average number of bits in the gray level set of the image, and it describes the average amount of information of the image source. The color entropy calculation of the image is to first calculate the image entropy for the three channels and then average the information of the three channels. The image entropy calculation formula is as follows: where p i is the probability that a certain gray level appears in the image. The edge information is obtained by the Sobel [37] detector, and the calculation formula is as follows: Gy where f(a, b) represents the quaternion value of the point (a, b). The horizontal and vertical gray value of each pixel of the image is calculated by the following formula: Brightness corresponds to imaging brightness and image gray and is the brightness of the color. According to the sensitivity of the human eye to the three primary colors of R, G, and B, three different coefficients are obtained. The brightness calculation formula is

Image contrast enhancement approach.
In this work, the input image is first represented by quaternion, and the image function is used as input. To generate an augmented image from an input image, a parametric transformation function is defined using Eq (6), which combines global and local information of the input image. The transformation function contains four parameters, namely, κ, a, b, and c. These four parameters have their defined ranges, and different values produce different enhanced images. Our goal is to find the set of values for these four parameters that produce the best results (according to fitness function values) using PSO. Through the steps on image representation, image transformation, and fitness function, this section describes the algorithm steps and advantages for image contrast enhancement on the bases of the improved particle swarm algorithm.
Initialization. In this step, using particle swarm-related parameters such as population size, search space range, and velocity, among others, the initial solution is obtained. At the same time, the parameters of κ, a, b, and c in the transformation function are initialized. First, P particles are initialized. The position vector of each particle X has four components, namely, k, a, b, and c. Now, using these parameter values, each particle generates an enhanced image using the intensity transformation function defined in Eq (6). The transform function is applied to each pixel in the input image, takes parameter values from each particle, and generates a modified intensity value for that pixel. Thus, each generation produces P enhanced images, and the quality of each enhanced image is measured by the objective function (fitness function) defined in Eq (16).
In the traditional particle swarm algorithm, the fitness values of all enhanced images generated by all particles are calculated. In PSO, the most attractive property is the direction in which PBEST and GBEST are responsible for driving each particle (solution) to the best position. In each iteration, P new positions are generated, and the PBEST and GBEST of each generation are found according to their fitness values. With the help of these two optimal values, the component new velocities of each particle are calculated to obtain the optimal solution used. When the process is complete, the augmented image is created from the GBEST position of the particle as it provides the maximum fitness value.
When using traditional PSO for image enhancement, only two items, namely, PBEST and GBEST, are considered. To further increase the diversity of particles, this paper adds a local optimum for topology calculation to fully utilize the diversity of particles. Therefore, the quaternion representation image is iteratively updated by formula 6 to update the velocity and position of particles. Then, formula 16 calculates the fitness value of the augmented image generated by all particles. In each step of iteration, P new positions will be generated. The individual optimum, global optimum, and local optimum of each generation are found according to the fitness value. When the three are balanced, the obtained optimum value is the global optimum. Fig 2 shows the flowchart of the algorithm.

Experimental results
This paper verifies the effectiveness of the algorithm via two experiments. First, it simulates and tests the improved particle swarm algorithm, and then, it verifies the convergence performance of the algorithm by standard test functions. Second, for the image enhancement method, the images in the test set are selected and evaluated via subjective vision and objective quality criteria.

Improved PSO experimental simulation
This paper selects six benchmark test functions (two single-peak functions, two multi-peak functions, and two multi-peak fixed-dimensional test functions) as shown in Table 1 for the algorithm. Verification is performed to determine the minimum value of the function, and the results of benchmark function optimization are compared and analyzed with the basic PSO, EDAPSO [38], and TPSO [39], and the algorithm proposed in this paper. Experimental data are noted to observe the same convergence efficiency and search accuracy of the algorithm under the same test function.
According to the parameters required for the experiment, the parameters are set as follows: the maximum number of iterations is 1000, inertia weight ω = 0.8, contraction factor χ = 0.729, and particle size popsize = 30. The results of the experiment on the improved algorithm are that c 1 , c 2 , and c 3 represent random numbers that the particle learns from individual optimal, local optimal, and global optimal, respectively. When c 1 = 1.4, c 2 = 1.4, c 3 = 1.8, the effect is better.
To easily check the performance of different algorithms, this research compares the traditional PSO, EDAPSO, TPSO, and the algorithms. Each algorithm is independently run 30 times for the six test functions in Table 1. Table 2 shows the minimum, average, and average

PLOS ONE
times. By comparing the data in Table 2, the improved PSO algorithm has obvious advantages over the other three PSO, EDAPSO, and TPSO. Considering that the local optimal value is added to the algorithm in this paper and comparing the data in the table, the algorithm in this paper can converge to the global optimal value, especially in F3, F5, and F6, after the ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi https://doi.org/10.1371/journal.pone.0274054.t001

PLOS ONE
comparison of the minimum value and the optimal value of the function. For the single-peak function, comparing the average values of several algorithms, the average value can be concluded to have increased by 4-10 times. For the Schwefel problem 2.2 functions, the average value of convergence has been improved qualitatively, which means the improved algorithm in this paper improved the search accuracy higher than the other three algorithms, and the diversity of particles is fully utilized. For multi-peak functions, a large number of local extremums are included in the entire function search space. The PSO algorithm can easily cause it to fall into local extremums. However, the improved PSO uses the comparison of topological structures to obtain the diversity of particles. Full use makes the algorithm reach a balance in the learning process and enables it to stand out from the local optimal value, allowing it to continue searching for the global optimal value. For the multimodal fixed-dimensional test function, the solutions obtained by different algorithms have little difference due to its low solution space dimension. Although no true value was found, the improved algorithm in this paper generates better search results. Fig 3 shows the convergence curves of several algorithms applied to the same constraint function. Evidently, the improved PSO algorithm has better convergence than the other three algorithms.
Given that this paper uses a deep topology, it has a certain impact on the time complexity of the entire algorithm. Owing to the addition of a sparse penalty term, the final time complexity presents a middle level. It carries out theoretical analysis and comparison of the average computational time complexity of the proposed algorithm and the traditional PSO algorithm. According to the description of the two algorithms, for the traditional PSO algorithm, the number of particles in each iteration is unchanged. Suppose the number of particles in the i-th

PLOS ONE
iteration is N i , where i = 1, 2,. . .,m, where m represents the maximum number of iterations; thus, N 1 = N 2 = . . . = N m = N. Assuming that the computing time required for each iteration of each particle is T T , the total running time required by the traditional PSO algorithm for optimization can be concluded to be N × m × T T . For the algorithm in this paper, the number of particles slowly decreases with the iteration, that is, N 1 � N 2 . . . � N m . Assuming that the computing time required for each iteration of each particle is T D , the total running time required by the algorithm in this paper after optimization is From the above analysis, the difference in the complexity of the two algorithms is reflected in the number of particles in each iteration and the running time required for each iteration of each particle.
For the traditional PSO algorithm, the operations required for a particle to update are as follows: 5 multiplications and 5 additions. The times required for multiplication and addition operations are assumed to be T m and T a . In the experiment, the number of particles in the traditional PSO algorithm is set to 50, and the number of iterations is m. Therefore, the average time required for the traditional PSO algorithm to complete the optimization is N×m×T T = m×50×(5T m +5T a ). For the algorithm in this paper, the operations required for a particle to compare and update are as follows: 5 4 n T m n ¼ 1; 2; . . . ; m ð Þ multiplications and 5 4 n T a n ¼ 1; 2; . . . ; m ð Þ additions. In the experiment, the maximum number of iterations is set to 1,000. Therefore, the average time required for the algorithm in this paper to complete the optimization is where N i represents the number of particles in the i-th iteration. When n progressively enlarges, 5 4 n continuously diminishes. After adding the sparse penalty coefficient, the sub-optimal solution is penalized, and the average time of the algorithm in this paper tends to N×m×T T = m×50×(T m +T a ). Given that the number of particles in each iteration of the algorithm in this paper is different, conducting multiple experiments, counting the number of particles in the corresponding iterations, and calculating the average number of particles in the corresponding iterations are necessary.

Algorithm performance evaluation 4.2.1 Subjective evaluation of image quality.
According to the description in [40], the evaluation methods of image quality can be divided into two categories: subjective and objective. The only subjective evaluation is the Mean Opinion Score (MOS), which means that many people judge the quality of an image, and the average of their scores is used as the evaluation result. We use the Mean Opinion Score (MOS) to reinforce the assumption that our proposed contrast enhancement algorithm can better match the human visual system's direct observations of the scene. Subjective experiments were conducted by 30 non-professional audience members who analyzed the color, contrast, sharpness, and texture of the fused images and were usually divided into two categories: absolute evaluation and relative evaluation. Absolute evaluation means that the scorer observes the image and provides the score according to the direct perception of the image. Table 3 lists the 5-level absolute scales listed in the relevant international documents, which are divided into obstructive and quality scales. Obstruction scales are mostly used by professional graders, while quality scales are more widely used. The relative evaluation is to let the raters observe a batch of images, classify them from good to bad, and provide the corresponding scores. Table 4 is a comparison table of the absolute and relative evaluation scales. Observers rated their quality from 5 (excellent) to 1 (very poor).

Objective evaluation of image quality.
In objective image quality evaluation, the main evaluation indicators include peak signal-to-noise ratio (PSNR), structural similarity index measure (SSIM) [41], information fidelity criterion (IFC) [42], visual information fidelity (VIF) [43], feature similarity (FSIM) [44], Information Entropy (Entropy), and Average Gradient (AG). Several evaluation indicators are thoroughly described below: (1) PSNR is generally used for an engineering project between maximum signal and background noise. To measure the image quality after processing, the PSNR value is generally used to measure whether a processing program is satisfactory. It is the logarithm of the mean square error between the original image and the processed image with respect to (2 n − 1) 2 (the square of the maximum value of the signal, n is the number of bits per sample), and its unit is dB. PSNR is defined by the mean square error (MSE), two images I and K, sizes are M × N, if one is the noise approximation of the other; the mean square error is defined as follows: Therefore, the PSNR is defined as where MAX I represents the maximum value of the image point color.
(2) SSIM. The human visual system can highly adaptively extract the structural information in the scene. Considering the distortion of the image by comparing the changes in the image structure information, the objective quality evaluation SSIM is obtained. The evaluation model of SSIM is as follows:

PLOS ONE
where x and y are the reference and images to be tested, and m x ; m y ; s 2 x ; s 2 y ; s xy is the mean, variance, and covariance of the images x and y. C 1 , C 2 is a small positive number to avoid instability due to zero denominator in the above formula. The closer x is to y, the closer the value of SSIM (x, y) is to 1. The closer the SSIM is to 1, the better the quality of the image.
(3) IFC. According to the IFC standard, the mutual information between the content observed by the human eye and the content of the image itself is assumed to be positively correlated, that is, the mutual information between the image information observed by the human eye and the content of the image itself characterizes the content observed by the human eye. When the image is distorted, the amount of mutual information between the observed and original images will decrease. If we can calculate the mutual information of the original reference image and the distorted image observed by the human eye and then calculate the mutual information of the original reference image and the reference image observed by the human eye, we can calculate the proportion of the information of the distorted image. The ratio of the amount of reference image information that the human eye can accept and this ratio can also characterize the image quality of the distorted image, which is the index we ultimately require.
(4) VIF. Starting from the knowledge of information theory, the distorted image is regarded as a decrease in information fidelity. The common information of the reference image and the test image is correlated, that is, the mutual information of the two is correlated. Mutual information is a statistical measure of information fidelity. Although it is not strongly correlated with image quality, it can limit the extraction of cognitive information from images. Information fidelity explores the relationship between visual quality and image information. Association. In the VIF evaluation model, the input image, the image distortion channel, and the distorted image model are all assumed to be accurate. The VIF indicator can be expressed as I C k r ; E k jz k r À � and I C k r ; F k jz k r À � are the corresponding mutual information measurements of the k-th sub-band, respectively, where k is the number of sub-bands.
(5) FSIM. FSIM is an image evaluation index based on the underlying features. It uses phase consistency to extract the underlying features of the image, which is closer to the human visual system. The main calculation methods are where PC m x; y ð Þ ¼ max PC x ð Þ; PC y ð Þ ð Þ is used to weight the overall similarity of the image x and y. S PC (x, y) represents the feature similarity of images x and y, S G (x, y) represents the gradient similarity, PC represents the phase consistency information, and G represents the gradient amplitude of the image. The constant is introduced to avoid the situation where the denominator is zero in the above format. The larger the value of FSIM, the more similar the reference image and the image to be tested and the higher the quality of the image to be tested, and vice versa, and the lower the quality of the image to be tested.
(6) AG. The average gradient can reflect the detailed contrast and texture transformation in the image. It somewhat reflects the clarity of the image. The calculation formula is ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi @f @x M×N represents the size of the image, @f @x represents the gradient in the horizontal direction, and @f @y represents the gradient in the vertical direction.

Results and analysis.
This study selected six images from two test image sets, and it performs contrast enhancement on different algorithms. In order to reflect the effectiveness of the algorithm in this paper, the images used in this paper are images from other datasets and network images as a reference, and we collect multiple low-contrast images in different scenes. The figure shows the effect of the enhancement. This paper selects six images from two data sets as reference images and compares them with other seven types on the bases of evolution. Contrast image enhancement methods were compared, including the following: based on artificial bee colony algorithm, cuckoo search algorithm, scoring algorithm, butterfly algorithm, genetic algorithm, and basic particle swarm algorithm; and performance evaluation using 7-image quality criteria. All these criteria are widely used in the field of image contrast enhancement and evaluate the performance of various image contrast enhancement methods. The parameters of all methods set the maximum number of iterations at 50, and the swarm of population size is set to be 50. All test images use the same parameter settings because the proposed method is quite robust to the choice of parameters used. The diagrams and tables show that this method is superior to other optimization algorithms for image enhancement methods and achieves the best image visual quality and the best target performance. Table 9 shows the calculation time of the seven algorithms for different images. The table clearly shows that the running time of the proposed algorithm is improved qualitatively compared with other algorithms. The optimal value is shown in bold. Table 10 shows the MOS scores of Figs 1-4 under several image enhancement methods. By comparing the MOS of several algorithms, the results show that our method achieves the highest MOS value on all enhanced images, which indicates that the method is visually superior to other state-of-the-art algorithms.
Another experiment was conducted to compare the proposed approach with a few recent image contrast enhancement approaches using selected images. Fig 5 presents the input images and enhancement images. Tables 11-14 are the objective index data of the enhanced images obtained by the four test images according to different algorithms.  correspond to the comparative data of different performance indexes of an image under the four algorithms, where one can see that the proposed approach can enhance the image contrast. Table 15 shows the calculation time of the four algorithms for different

PLOS ONE
images. The table shows that the running time of the proposed algorithm is improved qualitatively compared with other algorithms. Table 16 shows the MOS scores of images 5-8 under several image enhancement methods. By comparing the MOS of several algorithms, the results show that our method achieves the highest MOS value on all enhanced images, which indicates that the method is visually superior to other state-of-the-art algorithms.

Conclusions
With the aim to address the issue of long processing time and poor quality of low contrast enhancement by evolutionary algorithm optimization, this paper proposes an improved

PLOS ONE
particle swarm algorithm to optimize the low contrast color image enhancement algorithm. This algorithm used the quaternion matrix to represent the three channels of RGB images. The matrix can perform function transformation and parameter optimization. In the parameter optimization stage, an improved particle swarm algorithm is used. In the improved algorithm, the individual optimization of the particles, local optimization, and global optimization are used to adjust the particle's flight direction. Local optimization uses a topological structure,

PLOS ONE
and the particles communicate with each other. The local optimal solution is obtained, which not only increases the diversity of particles but also prevents subsequent particles from stopping iteration because they are trapped in local optimization. At the same time, a sparse penalty term is added to the speed update formula. The function of this term is to eliminate the least solution and reduce the iteration time. In the contrast enhancement process, the transformation function and the fitness value function are used to change the image quality. The algorithm in this paper adds contrast elements and brightness elements to the fitness function and uses the fitness function in guiding the particle swarm algorithm to optimize the four parameters in the transformation function. This article compares the proposed algorithm with other evolutionary algorithms to optimize the contrast enhancement. The images in two different data sets are selected for subjective and objective evaluation. The result implies the superiority of the effect in both subjective-qualitative and objective quantitative aspects.
Supporting information S1 Table. Relevant data underlying the findings described in Table 2.
(XLSX) S2 Table. Relevant data underlying the findings described in Tables 10 and 16.